<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <!-- 第1步,引入vue文件,去https://cdn.bytedance.com/找 -->
    <script
      src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/vue/2.6.14/vue.js"
      type="application/javascript"
    ></script>
  </head>
  <body>
    <!-- 第2步创建根组件元素 -->
    <div id="app">
      <!-- <el-input @keyup="onKeyup"></el-input> -->

      <!-- <div  @keyup.enter="onKeyup">
        <el-input></el-input>
      </div> -->
      
      <el-input @keyup.enter.native="onKeyup"></el-input>
    </div>
  </body>
  <script>
    // 方式一 通过父子组件通信实现监听
    // enter按键修饰符,不能用于组件通信
    // Vue.component("el-input", {
    //   template: `
    //   <div><input @keyup="$emit('keyup')" ></input></div>
    //   `
    // });
    Vue.component("el-input", {
      template: `
      <div><input></input></div>
      `,
    });
    //第3步,创建vue的实例
    new Vue({
      el: "#app",
      methods: {
        onKeyup(e) {
          console.log(e);
          console.log(123);
        },
      },
    });
  </script>
</html>
